package cn.airnan.dg.utils;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class CommonResponse<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> CommonResponse<T> success(T data) {
        return new CommonResponse<T>(0, "success", data);
    }

    public static <T> CommonResponse<T> success() {
        return new CommonResponse<T>(0, "success", null);
    }

    public static <T> CommonResponse<T> error(String msg) {
        return new CommonResponse<T>(1, msg, null);
    }
}